home *** CD-ROM | disk | FTP | other *** search
- Path: digex.net!not-for-mail
- From: dave@access2.digex.net (Dave Eidman)
- Newsgroups: comp.lang.c++
- Subject: Problem with C++ name mangling of Windows C exported functions
- Date: 24 Jan 1996 12:07:04 -0500
- Organization: Express Access, Greenbelt, Maryland USA
- Message-ID: <4e5ovo$1ap@access2.digex.net>
- NNTP-Posting-Host: access2.digex.net
-
- If anyone can shed some light on the following problem, I would appreciated it.
-
- In Borland C++ 4.5,
-
- I am able to compile and execute the following example that comes from
- Chap. 19 in the Petzold book "Programing Windows 3.1" using the
- DOS command line,
-
- bcc -c -ms! -w-par -P -W -2 strlib.c
-
- But utilizing the IDE, I encounter the indicated errors when the code
- attempts to turn off name mangling for exported functions.
-
- CONTENTS OF ERROR WINDOW IS AS FOLLOWS:
- -----------------------------------------------------------------------------------------------
- Compiling STRLIB.C:
- Error STRLIB.H 7: Declaration terminated incorrectly
- Error STRLIB.C 9: Declaration terminated incorrectly
- Warning STRLIB.C 23: Parameter 'hInstance' is never used in function LibMain
- Warning STRLIB.C 23: Parameter 'wDataSeg' is never used in function LibMain
- Warning STRLIB.C 23: Parameter 'lpszCmdLine' is never used in function LibMain
- Warning STRLIB.C 28: Parameter 'nParam' is never used in function WEP
- Error STRLIB.C 52: Undefined symbol 'hStrings' in function AddString
- Error STRLIB.C 81: Undefined symbol 'hStrings' in function DeleteString
- Error STRLIB.C 107: Undefined symbol 'hStrings' in function GetStrings
-
- -----------------------------------------------------------------------------------------------
-
-
- The following is source code from the Petzold Book
-
- strlib.c:
- -----------------------------------------------------------------------------------------------
- /*------------------------------------------------
- STRLIB.C -- Library module for STRPROG program
- (c) Charles Petzold, 1992
- ------------------------------------------------*/
-
- #include <windows.h>
- #include "strlib.h"
-
- extern "C" {
- int FAR PASCAL _export WEP (int) ;
- }
-
- HANDLE hStrings [256] ;
- short nTotal = 0 ;
-
- int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
- LPSTR lpszCmdLine)
- {
- if (wHeapSize > 0)
- UnlockData (0) ;
-
- return 1 ;
- }
-
- int FAR PASCAL _export WEP (int nParam)
- {
- return 1 ;
- }
-
- BOOL FAR PASCAL _export AddString (LPSTR lpStringIn)
- {
- HANDLE hString ;
- NPSTR npString ;
- short i, nLength, nCompare ;
-
- if (nTotal == 255)
- return FALSE ;
-
- if (0 == (nLength = lstrlen (lpStringIn)))
- return FALSE ;
-
- if (NULL == (hString = LocalAlloc (LHND, 1 + nLength)))
- return FALSE ;
-
- npString = LocalLock (hString) ;
- lstrcpy (npString, lpStringIn) ;
- AnsiUpper (npString) ;
- LocalUnlock (hString) ;
-
- for (i = nTotal ; i > 0 ; i--)
- {
- npString = LocalLock (hStrings [i - 1]) ;
- nCompare = lstrcmpi (lpStringIn, npString) ;
- LocalUnlock (hStrings [i - 1]) ;
-
- if (nCompare > 0)
- {
- hStrings [i] = hString ;
- break ;
- }
- hStrings [i] = hStrings [i - 1] ;
- }
-
- if (i == 0)
- hStrings [0] = hString ;
-
- nTotal++ ;
- return TRUE ;
- }
-
- BOOL FAR PASCAL _export DeleteString (LPSTR lpStringIn)
- {
- NPSTR npString ;
- short i, j, nCompare ;
-
- if (0 == lstrlen (lpStringIn))
- return FALSE ;
-
- for (i = 0 ; i < nTotal ; i++)
- {
- npString = LocalLock (hStrings [i]) ;
- nCompare = lstrcmpi (npString, lpStringIn) ;
- LocalUnlock (hStrings [i]) ;
-
- if (nCompare == 0)
- break ;
- }
-
- if (i == nTotal)
- return FALSE ;
-
- for (j = i ; j < nTotal ; j++)
- hStrings [j] = hStrings [j + 1] ;
-
- nTotal-- ;
- return TRUE ;
- }
-
- short FAR PASCAL _export GetStrings (FPSTRCB lpfnGetStrCallBack, LPVOID lpParam)
- {
- BOOL bReturn ;
- NPSTR npString ;
- short i ;
-
- for (i = 0 ; i < nTotal ; i++)
- {
- npString = LocalLock (hStrings [i]) ;
- bReturn = lpfnGetStrCallBack (npString, lpParam) ;
- LocalUnlock (hStrings [i]) ;
-
- if (bReturn == FALSE)
- return i + 1 ;
- }
- return nTotal ;
- }
-
- -----------------------------------------------------------------------------------------------
-
- strlib.h
-
- -----------------------------------------------------------------------------------------------
- /*----------------------
- STRLIB.H header file
- ----------------------*/
-
- typedef BOOL (FAR PASCAL _export * FPSTRCB) (LPSTR, LPVOID) ;
-
- extern "C" {
- BOOL FAR PASCAL _export AddString (LPSTR) ;
- BOOL FAR PASCAL _export DeleteString (LPSTR) ;
- short FAR PASCAL _export GetStrings (FPSTRCB, LPVOID) ;
- }
-
- -----------------------------------------------------------------------------------------------
-
- The windows.h file is the Version 3.10 that is included with BC4.5
- in the file "\bc45\include\windows.h"
-
-
-
- Thanks for any explanations that you can provide
-
- dave@access.digex.net
-
-